var vecUrl =
  "http://t0.tianditu.com/vec_w/wmts?tk=067998e486ea7ea61c91442ec719e8b3";
var cvaUrl =
  "http://t0.tianditu.com/cva_w/wmts?tk=067998e486ea7ea61c91442ec719e8b3";
var satUrl =
  "http://t0.tianditu.com/img_w/wmts?tk=067998e486ea7ea61c91442ec719e8b3";
var terUrl =
  "http://t0.tianditu.com/ter_w/wmts?tk=067998e486ea7ea61c91442ec719e8b3";
let baseurl =
  "&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=tiles&LAYER=";
var tdtVec = {
  type: "raster",
  tiles: [vecUrl + baseurl + "vec"],
  tileSize: 256,
};
var tdtSat = {
  type: "raster",
  tiles: [satUrl + baseurl + "img"],
  tileSize: 256,
};
var tdtTer = {
  type: "raster",
  tiles: [terUrl + baseurl + "ter"],
  tileSize: 256,
};
var tdtCva = {
  type: "raster",
  tiles: [cvaUrl + baseurl + "cva"],
  tileSize: 256,
};
function TileMap(raster, cav) {
  return {
    version: 8,
    sources: {
      "raster-tiles": {
        tiles: raster,
        type: "raster",
        tileSize: 256,
      },
      "cav-tiles": {
        tiles: cav,
        type: "raster",
        tileSize: 256,
      },
    },
    glyphs: "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
    sprite: "http://127.0.0.1:5501/lib/sprite",
    // sprite: "mapbox://sprites/mapbox/street-v11",
    layers: [
      {
        id: "raster-tiles",
        type: "raster",
        source: "raster-tiles",
        minzoom: 0,
        maxzoom: 22,
      },
      {
        id: "cav-tiles",
        type: "raster",
        source: "cav-tiles",
        minzoom: 0,
        maxzoom: 22,
      },
    ],
  };
}
export var basemaps = {
  tdtVec: {
    name: "天地图街道",
    value: TileMap(tdtVec.tiles, tdtCva.tiles),
  },
  tdtSat: {
    name: "天地图影像",
    value: TileMap(tdtSat.tiles, tdtCva.tiles),
  },
  tdtTer: {
    name: "天地图地形",
    value: TileMap(tdtTer.tiles, tdtCva.tiles),
  },
  mapboxDark: { name: "MapBox黑色", value: "mapbox://styles/mapbox/dark-v10" },
  mapboxStreet: { name: "MapBox街道", value: "mapbox://styles/mapbox/streets-v11" },
  mapboxOutDoor: {
    name: "MapBox户外",
    value: "mapbox://styles/mapbox/outdoors-v11",
  },
  mapboxLight: { name: "MapBox轻量", value: "mapbox://styles/mapbox/light-v10" },
  mapboxSat: { name: "MapBox卫星", value: "mapbox://styles/mapbox/satellite-v9" },
  mapboxSatStreet: {
    name: "MapBox卫星街道",
    value: "mapbox://styles/mapbox/satellite-streets-v11",
  },
  mapboxNight: {
    name: "MapBox夜晚",
    value: "mapbox://styles/mapbox/navigation-night-v1",
  },
  mapboxDay: {
    name: "MapBox白天",
    value: "mapbox://styles/mapbox/navigation-day-v1",
  },
  blank: {
    name: "纯色底图",
    value: {
      version: 8,
      name: "BlankMap",
      glyphs: "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
      sources: {},
      layers: [
        {
          id: "background",
          type: "background",
          paint: { "background-color": "#08294A" } /* 背景颜色 */,
        },
      ],
    },
  },
};
